/**
 * 项目名：phms3
 * 日期：    2019-12-07 21:52:46
 * Copyright (c) 2015- HTSC-版权所有
 */
package com.joysuch.wwyt.bp.repository;

import com.joysuch.wwyt.bp.bean.BpSystemVideoAddBean;
import com.joysuch.wwyt.bp.entity.BpSystemVideo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

import java.util.List;


/**
 * BpSystemVideoDao
 */
public interface BpSystemVideoDao extends JpaRepository<BpSystemVideo, Long>, QuerydslPredicateExecutor<BpSystemVideo> {

    public Page<BpSystemVideo> findAll(Specification<BpSystemVideo> spec, Pageable pageable);

    public BpSystemVideo save(BpSystemVideo bean);

    public void delete(BpSystemVideo bean);


    //    @Query(value = "SELECT COUNT(NAME) FROM wwyt_bp_system_video WHERE NAME = ?1 AND BRAND = ?2 AND DELETE_FLAG = '0'" ,nativeQuery = true)
    int countByNameAndBrand(String name, String brand);

    @Query(value = "select * from wwyt_bp_system_video where name =?1 and brand =?1 and delete_flag ='0'", nativeQuery = true)
    List<BpSystemVideo> findByNameAndBrand(String name, String brand);

    @Query(value = "select * from wwyt_bp_system_video where REGION is not null and DELETE_FLAG = '0' " , nativeQuery = true)
    List<BpSystemVideo> findAllHaveLocation();

    @Query(value = "select * from wwyt_bp_system_video where  DELETE_FLAG = '0' and id in ?1 " , nativeQuery = true)
    List<BpSystemVideo> findByIds(List<Long> facilityVideoIds);
}
